const multer  = require('multer');
const path = require('path')
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/uploads')
  },
  filename: function (req, file, cb) {
    const extname = path.extname(file.originalname)
    cb(null, file.fieldname + '-' + Date.now()+extname)
  }
})

const upload = multer({ storage })

module.exports = upload